<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>JavaScript获取字符串中单个字符</title>
    </head>
    <body>
        <h3>JavaScript获取字符串中单个字符</h3>
        <hr />
        <script>
            //声明变量msg
            var msg = "Hello JavaScript";
            //获取字符串中单个字符
			var letter = msg.charAt(10);
			//获取字符串中单个字符的代码
			var code= msg.charCodeAt(10);
            alert("Hello JavaScript在第10位上的字符为："+letter+"\n其字符代码为："+code);
        </script>
    </body>
</html>